package com.ncd.disease.controller;

import com.ncd.common.annotation.Log;
import com.ncd.common.core.controller.BaseController;
import com.ncd.common.core.domain.AjaxResult;
import com.ncd.common.enums.BusinessType;
import com.ncd.disease.domain.RetAdmInfo;
import com.ncd.disease.service.IRetAdmInfoService;
import com.ncd.disease.service.IRetAdmService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 患者复诊明细Controller
 * 
 * @author zhouxin
 * @date 2024-03-10
 */
@Controller
@RequestMapping("/disease/adminfo")
public class RetAdmInfoController extends BaseController
{
    private String prefix = "disease/adminfo";

    @Resource
    private IRetAdmInfoService retAdmInfoService;

    @Resource
    private IRetAdmService retAdmService;

    /**
     * 修改患者基本信息
     */
    @RequiresPermissions("disease:adminfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        mmap.put("adm", retAdmService.getById(id));
        mmap.put("admInfo", retAdmInfoService.selectRetAdmInfoByAdmId(id));
        return prefix + "/edit";
    }

    /**
     * 修改保存患者基本信息
     */
    @RequiresPermissions("disease:adminfo:edit")
    @Log(title = "患者复诊信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody RetAdmInfo retAdmInfo)
    {
        return toAjax(retAdmInfoService.saveOrUpdate(retAdmInfo));
    }


}
